﻿@using RBS.Web.Controllers
@model RBS.Core.Model.Hotel.H_Hotels
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var uid = -1;
    if (Request.IsAuthenticated)
    {
        uid = Convert.ToInt32(Context.User.Identity.Name);
    }  
    <script>
        var Img = new Array();
        var size = 0;
        var i = 0;
        var loadImg= new Array(); 
        $(function () {
            GetHotelImg();  
        }); 
            
        //酒店图片
        function GetHotelImg() {
            var url = "@Url.Action("GetHotelImg")?hid=" + @Model.H_id;
            $.ajax({
                url: url,
                type: 'Post',
                dataType: 'json',
                success: function (result) {   
                    if (result == null)
                        return;  
                    
                    $("#testTable").empty();
                    $.each(result.Data, function (index, row) { 
                        Img[index] = "@(RBS.Common.ConfigHelper.GetConfigString("hotelWeb"))" + row.ImgSrc;
                        var template = $('#HotelImgTemplate').html(); //获取模版的html
                        var bookData = Mustache.render(template, row);//把每行的数据填充到模版得到html内容
                        $("#testTable").append(bookData);
                    }); 
                    $('#bigpicsrc').attr('src', "@(RBS.Common.ConfigHelper.GetConfigString("hotelWeb"))"+result.Data[0].ImgSrc);  
                    $('#bigpicsrc-a').attr('href', "@(RBS.Common.ConfigHelper.GetConfigString("hotelWeb"))"+result.Data[0].ImgSrc);  
                    
                    $('.smallpicin img').each(function (index) { 
                        $(this).click(function () { 
                            $("#p").html(index+1);  
                            $('#bigpicsrc').attr('src', this.src);
                            $('#bigpicsrc-a').attr('href',this.src);  
                            });  
                      }); 
                    size = Img.length;
                    $("#count").html(size);
                    $("#p").html(i+1);
                    for (i=0;i<size;i++){
                        loadImg[i] = new Image();
                        loadImg[i].src = Img[i];
                    }
                    i = 0;
                }
            }); 
        } 
            
        //判断登录
        function checkLogin() {
            if (@uid==-1) { 
                var url = "@Url.Action("Index", "Login", new { redirectUrl = Request.Url })";
                window.location = url;
                return false;
            } 
            return true;  
        } 
      
        function nextImg() { 
            i++;
            if (i>=size) i=0; 
            $('#bigpicsrc').attr('src',  Img[i]);
            $('#bigpicsrc-a').attr('href',  Img[i]);  
            $("#p").html(i+1);
        }
        function preImg(){
            i--;
            if (i<=-1) i=size-1;
            $('#bigpicsrc').attr('src',  Img[i]);
            $('#bigpicsrc-a').attr('href',  Img[i]);  
            $("#p").html(i+1);
        }

    </script>
}

<div id="content">
    <div class="h1a">本地商户</div>
     @{
        @Html.Partial("_HotelHead",Model);
    }
    <div id="mainContent">
        <dl class="dtlcateg">
            <dd><a href="@Url.Action("Index", new { id = Model.H_id })">菜单</a></dd>
            <dd class="active"><a href="#">餐厅场景</a></dd>
            @*<dd><a href="#">点菜记录</a></dd>*@
            <dd><a href="@Url.Action("Comment", new { id = Model.H_id })">网友点评</a></dd>
        </dl>
        
        <div class="bigpic">
			<p><a class="example-image-link" data-lightbox="example-img"  id="bigpicsrc-a"><img id="bigpicsrc" src="images/2154210206.jpg"  class="example-image"/></a></p>
			<ul>
				<li><a href="javascript:;" onClick="preImg()">上一张</a></li>
				<li class="num"><span id="p"></span>/<span id="count"></span></li>
			    <li><a href="javascript:;" onClick="nextImg()">下一张</a></li>
                
 
			</ul>
		</div>
		<div class="smallpic">
			<div class="smallpicin">
				<ol id="testTable">  
				</ol>
			</div> 
        <script type="text/template" id="HotelImgTemplate">
            <li>
            <img src="@(RBS.Common.ConfigHelper.GetConfigString("hotelWeb")){{ImgSrc}}"  class="example-image"/> </li>
        </script>
       

    </div>
    <div id="sideContent">
        <div class="mymenu">
            <h2>广告区域</h2>
            <div>
            </div>
        </div>
    </div>
</div>
